package com.bolehui.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bolehui.base.result.Result;
import com.bolehui.domain.po.Summary;
import com.bolehui.domain.vo.SummaryVO;
import com.bolehui.mapper.SummaryMapper;
import com.bolehui.service.SummaryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author chendongjie
 * @since 2025-03-18
 */
@Service
public class SummaryServiceImpl extends ServiceImpl<SummaryMapper, Summary> implements SummaryService {

    @Autowired
    private SummaryMapper summaryMapper;

    @Override
    public Result saveSummary(SummaryVO summaryVO, Long userId) {
        Summary summary = Summary.builder()
                .experienceDesc(summaryVO.getExperienceDesc())
                .candidateId(userId)
                .build();
        summaryMapper.insert(summary);
        return Result.success();
    }

    @Override
    public Result update(SummaryVO summaryVO, Long userId) {
        Summary summary = Summary.builder()
                .experienceDesc(summaryVO.getExperienceDesc())
                .build();
        summaryMapper.update(summary, new QueryWrapper<Summary>().eq("candidate_id", userId));
        return Result.success();
    }
}
